package cc.mrbird.febs.power.controller;


import cc.mrbird.febs.common.utils.R;
import cc.mrbird.febs.power.entity.RoleBindMenuInfo;
import cc.mrbird.febs.power.service.IRoleBindMenuInfoService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author MrBird
 */
@RestController
@RequestMapping("/power/role-bind-menu-info")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class RoleBindMenuInfoController {

    private final IRoleBindMenuInfoService iRoleBindMenuInfoService;

    /**
     * 根据角色获取菜单信息
     * @param roleId
     * @return
     */
    @GetMapping("/info/{roleId}")
    public R getMenuInfoByRoleId(@PathVariable("roleId") Integer roleId) {
        return R.ok(iRoleBindMenuInfoService.getMenuInfoByRoleId(roleId));
    }

    /**
     * 新增角色绑定菜单
     * @param roleBindMenuInfo
     * @return
     */
    @PostMapping("/RoleBindMenuInfoAdd")
    public R RoleBindMenuInfoAdd(RoleBindMenuInfo roleBindMenuInfo) {
        return R.ok(iRoleBindMenuInfoService.save(roleBindMenuInfo));
    }

    /**
     * 修改角色绑定菜单
     * @param roleBindMenuInfo
     * @return
     */
    @PutMapping("/RoleBindMenuInfoEdit")
    public R RoleBindMenuInfoEdit(RoleBindMenuInfo roleBindMenuInfo) {
        return R.ok(iRoleBindMenuInfoService.updateById(roleBindMenuInfo));
    }

    /**
     * 通过ID删除记录
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public R RoleBindMenuInfoDel(@PathVariable Integer id) {
        return R.ok(iRoleBindMenuInfoService.removeById(id));
    }

}
